package com.utils.picTxt
{
	import com.utils.ButtonModule;
	import com.utils.picTxt.pic.FaceGather;
	import com.utils.picTxt.richTextField.RichTextField;
	import com.utils.picTxt.richTextField.plugins.ShortcutPlugin;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.profiler.showRedrawRegions;
	import flash.text.TextFormat;
	import flash.utils.getDefinitionByName;
	import flash.utils.getQualifiedClassName;
	
	public class PicTxtEditor extends Sprite
	{
		private var _faceBtn:ButtonModule;
		private var _sendBtn:ButtonModule;
		private var _faceGather:FaceGather; 
		private var _inputTextPanel:InputTextPanel;
		private var _outputTextPanel:OutputTextPanel;

		private var _txtFormat:TextFormat;
		public function PicTxtEditor()
		{
			this.addEventListener(Event.ADDED_TO_STAGE,onAddToStage);
		}
		
		private function onAddToStage(e:Event):void
		{
			this.removeEventListener(Event.ADDED_TO_STAGE,onAddToStage);
			init();
		}		
		
		private function init():void
		{
			initInputPanel();
			initOutputText();
		}
		
		private function initOutputText():void
		{
			
		}
		
		private function initInputPanel():void
		{
			_inputTextPanel = new InputTextPanel(new ButtonModule('assets/images/chatIcon.png'),new ButtonModule(null,['发送']),415,105);
			_inputTextPanel.onSendMessage = sendMessage;
			this.addChild(_inputTextPanel);
			_inputTextPanel.y = this.stage.stageHeight - _inputTextPanel.height;
			
			_outputTextPanel = new OutputTextPanel(415);
			this.addChild(_outputTextPanel);
		}
		
		
		
		private function sendMessage(message:String):void
		{
			var date:Date=new Date();
			var timeStr:String = date.getFullYear()+'/'+(date.getMonth() + 1)+'/'+date.getDate()+' '+date.getHours()+':'+date.getMinutes()+':'+date.getSeconds();
			_outputTextPanel.showMsg(MsgTranscoding.titleXml(1,'test',timeStr));
			_outputTextPanel.showMsg(MsgTranscoding.strToXml(message));
		}
		
		
		
		
		
		
	}
}